package com.ssyx.home.controller;

import com.ssyx.common.auth.AuthContextHolder;
import com.ssyx.common.result.Result;
import com.ssyx.home.service.ItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * ClassName:ItemApiController
 * Description:
 *
 * @Author kay
 * @Create 2024/5/17 18:20
 * @Version 1.0
 */
@Tag(name = "商品详情接口")
@RestController
@RequestMapping("api/home")
public class ItemApiController {

    @Autowired
    private ItemService itemService;

    @Operation(summary = "获取sku详情信息")
    @GetMapping("item/{id}")
    public Result index(@PathVariable Long id, HttpServletRequest request) {
        Long userId = AuthContextHolder.getUserLoginVo().getUserId();
        Map<String, Object> map =  itemService.index(id, userId);
        return Result.ok(map);
    }
}
